package com.tanfuqi.sicent.server.advice

import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.ResponseStatus
import org.springframework.web.bind.annotation.RestControllerAdvice
import java.util.concurrent.TimeoutException

@RestControllerAdvice
class ExceptionAdvice {
    @ExceptionHandler(TimeoutException::class)
    @ResponseStatus(HttpStatus.REQUEST_TIMEOUT)
    fun timeoutAdvice(): Map<String,String> = mapOf("message" to "请求超时")

    @ExceptionHandler(ShopNotFoundException::class)
    @ResponseStatus(HttpStatus.NOT_FOUND)
    fun shopNotFound(): Map<String,String> = mapOf("message" to "未找到对应店面")
}

object ShopNotFoundException :Exception()